
var SDIsubNowShowing = null;
var SDIsubTimer = null;
var SDIsubDefault = null;
var mainSelectedAId=null;
var currentId = null;
var subselected = null;
var parId = null;

function sdi_Navigation(subID) {	//onmouseover
	if(currentId){
		sdi_setInactive(currentId);
	}
	sdi_subHideNow();//Immediately hides any open subnavigation
	if(subID!="")
		sdi_subShow(subID);
}

	
function sdi_setNavigation(subID){
	SDIsubDefault = subID;
	sdi_Navigation(SDIsubDefault);
}

function sdi_subHide(){	//onmouseout
	//SDIsubTimer = setTimeout("sdi_subHideNow()", 2000);	
	SDIsubTimer = setTimeout("callTimeOut()", 2000);
}

function sdi_subHideNow(){
	sdi_subShowContinued();//Stop timer
	if(SDIsubNowShowing && SDIsubNowShowing != SDIsubDefault){
		sdi_setInactive(SDIsubNowShowing);//Close 
	}	
	if(SDIsubDefault){sdi_setCurrent(SDIsubDefault);}
	SDIsubNowShowing = null;
}
function callTimeOut(){
	sdi_subHideNow();
	restoreShow();
}
function restoreShow(){
	if(currentId){
		sdi_setCurrent(currentId);
	}
} 

function sdi_subShow(subID){
	sdi_subShowContinued();//Stop timer
	if(SDIsubDefault && subID != SDIsubDefault){
		sdi_setInactive(SDIsubDefault);
	}
	sdi_setCurrent(subID);
	if(!SDIsubNowShowing){
		SDIsubNowShowing= subID;
	}
}

function sdi_subShowContinued(){
	if(SDIsubTimer){clearTimeout(SDIsubTimer);}
	SDIsubTimer = null;
}

function sdi_setCurrent(m){
	try{
		document.getElementById("sub"+m).style.display = "block";
		document.getElementById(m).className = "current";
	}catch(e){}
}

function sdi_setInactive(m){
	try{
		document.getElementById("sub"+m).style.display = "none";
		document.getElementById(m).className = "";
	}catch(e){}
}
function mainSelectedA(thisObj){	//onclick
	currentId = thisObj;
	if(mainSelectedAId){
		mainSelectedAId.style.color="#0076C4";
	}
	if(typeof(thisObj)!="object")
       thisObj=document.getElementById(thisObj);
    thisObj.style.color="#FF0000";
    mainSelectedAId=thisObj;
    
}
function mainSelectedB(thisObj,subId){	//onclick
	currentId = thisObj;
	if(mainSelectedAId){
		mainSelectedAId.style.color="#0076C4";
	}
	if(subselected){
		var ob = document.getElementById(subselected);
		ob.style.color="#024d23";
	}
	if(typeof(thisObj)!="object")
    	thisObj=document.getElementById(thisObj);
    thisObj.style.color="#FF0000";
    
    if(typeof(subId)){
    	var thisSubObj=document.getElementById(subId);
    	thisSubObj.style.color="#FF4500";
    }
    mainSelectedAId=thisObj;
    subselected=subId;
}
